home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / mac / Chapter Tutorials / CaseStudies / ch11.earshotSFX / earMenu.dir / 00002.ls < prev    next >
Encoding:
Text File  |  1996-11-12  |  4.7 KB  |  176 lines

  1. global gNullCastNum, gLHiliteList, gRHiliteList, gLeftGoToList, gRightGoToList, gPictInAStringL, gPictInAStringR, gLastRollover, gLastPiePiece
  2.  
  3. on localInit
  4.   setGlobals()
  5.   preloadSoundMovies()
  6. end
  7.  
  8. on preloadSoundMovies
  9.   global gLeftGoToList, gRightGoToList, gBaseURL
  10.   repeat with i = 1 to integer((count(gLeftGoToList) + count(gRightGoToList)) / 2) - 2
  11.     addToLoadQueue(getAt(gLeftGoToList, i) & ".dcr")
  12.     addToLoadQueue(getAt(gRightGoToList, i) & ".dcr")
  13.   end repeat
  14. end
  15.  
  16. on setGlobals
  17.   if not gPictInAStringL then
  18.     set gPictInAStringL to the text of cast "Left Mask Text"
  19.   end if
  20.   if not gPictInAStringR then
  21.     set gPictInAStringR to the text of cast "Right Mask Text"
  22.   end if
  23.   if not gLHiliteList then
  24.     set gLHiliteList to []
  25.     repeat with x = 1 to 18
  26.       add(gLHiliteList, the number of member ("Left Hilite" && string(x)))
  27.     end repeat
  28.     add(gLHiliteList, the number of member "Null Hilite")
  29.   end if
  30.   if not gRHiliteList then
  31.     set gRHiliteList to []
  32.     repeat with x = 1 to 18
  33.       add(gRHiliteList, the number of member ("Right Hilite" && string(x)))
  34.     end repeat
  35.     add(gRHiliteList, the number of member "Null Hilite")
  36.   end if
  37.   set gNullCastNum to the number of member "Null Hilite"
  38.   if not gLeftGoToList then
  39.     set gLeftGoToList to ["Phones", "Sci-Fi", "Human", "Swishes", "Industrial", "Vehicles", "Water", "Weather", "Whooshes", "Textures", "Household", "Squeaks", "Impacts", "Switches", "Liquids", "Media", "Monsters", "Office", "RightChoice"]
  40.   end if
  41.   if not gRightGoToList then
  42.     set gRightGoToList to ["Creaks", "Comedy", "Crowds", "Computers", "Doors", "Electrics", "Animals", "Fire", "Explosions", "Bells", "Alarms", "Ambience", "Beeps", "Arcade", "Guns", "Camera", "Buttons", "Gore", "LeftChoice"]
  43.   end if
  44.   if not gLastPiePiece then
  45.     set gLastPiePiece to 0
  46.   end if
  47. end
  48.  
  49. on GrayMatterPrint
  50.   beep()
  51. end
  52.  
  53. on initText
  54.   set gLastRollover to 48
  55.   repeat with channel = 10 to 14
  56.     puppetSprite(channel, 1)
  57.   end repeat
  58. end
  59.  
  60. on PupsOff
  61.   puppetSound(0)
  62.   repeat with channel = 10 to 21
  63.     puppetSprite(channel, 0)
  64.   end repeat
  65.   updateStage()
  66. end
  67.  
  68. on stopMovie
  69.   PupsOff()
  70. end
  71.  
  72. on checkRoll
  73.   repeat with spriteCounter = 10 to 14
  74.     set gLastRollover to 48
  75.     if rollOver(spriteCounter) and (spriteCounter <> gLastRollover) then
  76.       set gLastRollover to spriteCounter
  77.       puppetSound(0)
  78.       if not soundBusy(1) then
  79.         set theSound to "word" & spriteCounter
  80.         puppetSound(theSound)
  81.       end if
  82.       set the castNum of sprite spriteCounter to the number of member (spriteCounter & "hi")
  83.       updateStage()
  84.       repeat while rollOver(spriteCounter) and the mouseUp
  85.       end repeat
  86.       set the castNum of sprite spriteCounter to the number of member (gLastRollover & "or")
  87.       updateStage()
  88.     end if
  89.   end repeat
  90. end
  91.  
  92. on LeftSide
  93.   set whichOne to FindColorOfPixelUnderCursorL()
  94.   if whichOne <> gLastPiePiece then
  95.     if whichOne = 0 then
  96.       set the castNum of sprite 2 to gNullCastNum
  97.     else
  98.       if whichOne = 19 then
  99.         set the castNum of sprite 2 to gNullCastNum
  100.         updateStage()
  101.         go(getAt(gLeftGoToList, whichOne))
  102.       else
  103.         puppetSound("click1.aif")
  104.         set the castNum of sprite 2 to getAt(gLHiliteList, whichOne)
  105.         set gLastPiePiece to whichOne
  106.         updateStage()
  107.       end if
  108.     end if
  109.   end if
  110. end
  111.  
  112. on RightSide
  113.   set whichOne to FindColorOfPixelUnderCursorR()
  114.   if whichOne <> gLastPiePiece then
  115.     if whichOne = 0 then
  116.       set the castNum of sprite 2 to gNullCastNum
  117.     else
  118.       if whichOne = 19 then
  119.         set the castNum of sprite 2 to gNullCastNum
  120.         updateStage()
  121.         go(getAt(gRightGoToList, whichOne))
  122.       else
  123.         puppetSound("click1.aif")
  124.         set the castNum of sprite 2 to getAt(gRHiliteList, whichOne)
  125.         set gLastPiePiece to whichOne
  126.         updateStage()
  127.       end if
  128.     end if
  129.   end if
  130. end
  131.  
  132. on LaunchLeftChoice
  133.   set whichOne to FindColorOfPixelUnderCursorL()
  134.   if whichOne = 0 then
  135.     exit
  136.   else
  137.     goMovie(getAt(gLeftGoToList, whichOne) & ".dcr")
  138.   end if
  139. end
  140.  
  141. on LaunchRightChoice
  142.   set whichOne to FindColorOfPixelUnderCursorR()
  143.   if whichOne = 0 then
  144.     exit
  145.   else
  146.     goMovie(getAt(gRightGoToList, whichOne) & ".dcr")
  147.   end if
  148. end
  149.  
  150. on initRollOvers
  151.   if the puppet of sprite 2 = 0 then
  152.     puppetSprite(2, 1)
  153.   end if
  154.   set the visible of sprite 2 to 1
  155. end
  156.  
  157. on LoadRawPictIntoString
  158.   if objectp(myObj) then
  159.     myObj(mdispose)
  160.   end if
  161. end
  162.  
  163. on FindColorOfPixelUnderCursorL
  164.   set x to the mouseH / 2
  165.   set y to the mouseV / 2
  166.   set locOfPixelInString to (y * 160) + x + 1
  167.   return charToNum(char locOfPixelInString of gPictInAStringL)
  168. end
  169.  
  170. on FindColorOfPixelUnderCursorR
  171.   set x to the mouseH / 2
  172.   set y to the mouseV / 2
  173.   set locOfPixelInString to (y * 160) + x + 1
  174.   return charToNum(char locOfPixelInString of gPictInAStringR)
  175. end
  176.